//
//  AXFFeebackController.m
//  AXFEightGroup
//
//  Created by hgj on 2016/12/22.
//  Copyright © 2016年 ya. All rights reserved.
//

#import "AXFFeebackController.h"
#import "AXFFeebackView.h"

@interface AXFFeebackController ()

@property(nonatomic,strong) AXFFeebackView *suggsetView;

@property (nonatomic, weak) UITextView *suggest_text;
@property (nonatomic, weak) UILabel *textNumber_text;

@end

@implementation AXFFeebackController {
    NSString *_title;
}

- (instancetype)initWithTitle:(NSString *)title {
    if (self = [super init]) {
        _title = title;
    }
    return self;
}

- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.title = _title;;
    
    [self setNav];
    
    AXFFeebackView *suggsetView = [AXFFeebackView loadsuggestView];
    
    typeof(self) weakSelf = self;
    suggsetView.Block = ^(UITextView *suggest_text, UILabel *textNumber_text) {
        weakSelf.suggest_text = suggest_text;
        weakSelf.textNumber_text = textNumber_text;
    };
    
    suggsetView.frame = self.view.bounds;
    
    self.suggsetView = suggsetView;
    
    [self.view addSubview:suggsetView];
    
}

- (void)setNav {
//    // 左上角返回按钮
//    UIBarButtonItem* leftItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"v2_goback"] style:UIBarButtonItemStylePlain target:self.navigationController action:@selector(popViewControllerAnimated:)];
//    
//    [[UINavigationBar appearance] setTintColor:[UIColor grayColor]];
//    
//    // 设置左上角的返回按钮
//    self.navigationItem.leftBarButtonItem = leftItem;
    
    // 右上角返回按钮
    
    UIBarButtonItem *rightitem = [[UIBarButtonItem alloc]initWithTitle:@"提交" style:UIBarButtonItemStylePlain target:self action:@selector(performButton)];
    
    [[UINavigationBar appearance] setTintColor:[UIColor grayColor]];
   
    // 设置右上角的返回按钮
    self.navigationItem.rightBarButtonItem = rightitem;
}

- (void)performButton {

    if (_suggest_text.text.length > 0) {
        
        _suggest_text.text = nil;
        
        [SVProgressHUD showSuccessWithStatus:@"提交成功"];
        _textNumber_text.text = @"200";
    } else {

        [SVProgressHUD showErrorWithStatus:@"反馈不能为空,请重新输入"];
    }
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    [self.view endEditing:YES];
}

@end
